package com.gsafety.libraryktx.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import java.util.*

/**
 * Created by admin on 2017/11/13.
 */
class CommonVPAdapter(fm: FragmentManager?) : FragmentStatePagerAdapter(
    fm!!
) {
    private val fragments: MutableList<Fragment>
    override fun getItem(position: Int): Fragment {
        return fragments[position]
    }

    override fun getCount(): Int {
        return fragments.size
    }

    fun setFragments(fragments: List<Fragment>) {
        this.fragments.addAll(fragments)
        notifyDataSetChanged()
    }

    init {
        fragments = ArrayList()
    }
}